<template>
	<view class="">
		<!-- #ifdef H5 -->
		<view class="zdex9 pt20 pb20" :style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
			<view class="flex alicen pl20 h60">
				<view class="w40b flex alicen">
					<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
					<view class="fz24 ml20 nowrap">指点教育高考预测系统</view>
				</view>
			</view>
		</view>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<u-sticky>
			<view class="zdex9 pb20" :style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
				<view class="">
					<view class="" :style="{'paddingTop':statusBarHeigh + 'px',}">
						<view class="flex alicen pl20" :style="{'height':menuButtonInfo.height + 'px',}">
							<view class="w40b flex alicen">
								<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
								<view class="fz24 ml20 nowrap">指点教育高考预测系统</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</u-sticky>
		<!-- #endif -->
		<view class="">
			<view class="pb20"></view>
			<view class="fz30 bold txtcen">专业组分析</view>
			<view class="pb20"></view>
			<view class=" ml20 mr20 pt20 pb20 pl20 pr20 bgfff ius20">
				<view class="flex alicen between">
					<view class="nowrap fz28">省市</view>
					<view @click="provinceBtn('S')"
						class="pt10 w60b mr10 bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 txtleft w80b text-word-break-1">{{provinceName||'不限'}}</view>
						<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
					</view>
				</view>
				
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校类型/性质</view>
					<view @click="natures('L')"
						class="pt10 mr10 w60b bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 txtleft w80b text-word-break-1">{{schoolTypesName||'不限'}}</view>
						<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
					</view>
				</view>
				
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校特色
					</view>
					<view @click="schollType('Y')"
						class="pt10 w60b mr10 bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 txtleft w80b text-word-break-1">{{schoolLevelName||'不限'}}</view>
						<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
					</view>
				</view>
				
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校</view>
					<view @click="checkBtn('X')"
						class="pt10 mr10 w60b bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 w70b txtleft text-word-break-1">{{schoolName||'不限'}}</view>
						<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
					</view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校代码</view>
					<view
						class="pt10 mr10 w60b bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 w70b text-word-break-1">
							<input class="w100b txtleft" type="number" placeholder="请输入学校代码"
								v-model="schoolcodeInput" />
						</view>
					</view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校名称</view>
					<view
						class="pt10 mr10 w60b bgfff flex alicen between mr10 pb10 pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 w70b text-word-break-1">
							<input class="w100b txtleft" type="text" placeholder="请输入学校名称" v-model="schollNameIut" />
						</view>
					</view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen between">
					<view class="nowrap fz28">学校批次</view>
					<view
						class="pt10 mr10 w60b bgfff flex alicen mr10 pb10 between pl20 pr20  nowrap col99 fz24  txtcen ius10 border1 boreb">
						<view class="mr10 w40b text-word-break-1">{{'本科普通批'}}</view>
						<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
					</view>
				</view>
				<view class="pb30"></view>
				<view class="flex">
					<view class="flex1 fz28 pb20 pt20 flexCenter ius100 border1 borf84746 col40" @tap.stop="resetBtn()">
						重置</view>
					<view class="pt20 flex2 ml20 pb20 ius100 colff ml20 mr20  bgff000 fz30 flexCenter" @click="analyse">
						分析</view>
				</view>
				<view class="pb60"></view>
				<view class="fz28 col40">功能说明</view>
				<view class="pb10"></view>
				<view class="mt10 fz24 col33">
					选择具体院校(或输入院校代码)点击分析后，
					系统根据该校前三年的录取详情给出院校专业组及专业录取概率。
				</view>
			</view>
		</view>
		<com-popup :showPop="popObj.showRightPop" @popStatus="(i) => {popObj.showRightPop = i,popObj.isLoad = {}}">
			<com-selectList :flag="flag" :typesign="popObj.typesign" :popTypeName="popObj.popTypeName"
				:popTypeValue="popObj.popTypeValue" :list="popObj.popList" :title="popObj.popTitle" @submit="display"
				v-if="popObj.isLoad.selectList">
			</com-selectList>
		</com-popup>
	</view>
</template>
<script>
	import config from "@/config.js";
	import {
		province_list,
		school_level,
		school_types,
		schoolNames
	} from "@/utils/api/dict.js"
	export default {
		data() {
			return {
				flag: false,
				provinceName: '', //选择的省份
				schoolLevelName: '', //学校性质
				schoolTypesName: '', //特色
				schoolName: '', //学校名称
				schollNameIut: '', //用户输入的学校名称
				schoolcodeInput: '', //学校代码
				popObj: {
					popTypeName: "",
					popTypeValue: "",
					showRightPop: false,
					popTitle: "",
					typesign: '', //自定义标识
					popList: [],
					isLoad: {}
				},
			};
		},
		onLoad() {
			this.$store.dispatch('clearState');
		},
		computed: {
			//省份
			province() {
				return this.$store.state.province
			},
			schoolTypes() {
				return this.$store.state.schoolTypes
			},
			schoolLevel() {
				return this.$store.state.leveltype
			},
			schoolcode() {
				return this.$store.state.schoolcode
			}
		},
		methods: {
			//重置事件
			resetBtn() {
				this.provinceName = ''
				this.schoolLevelName = ''
				this.schoolTypesName = ''
				this.schoolName = ''
				this.$store.dispatch('clearState');
			},
			//请求省份字典
			provinceBtn(flag) {
				this.popObj.popTypeName = "省份"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = flag //自定义标识
				province_list({
					scrollstr: true
				}).then(res => {
					let temp = []
					res.map((item) => {
						let obj = {
							name: item.name,
							value: item.id
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				})
			},
			schollType(flag) {
				this.popObj.popTypeName = "院校特点"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = flag //自定义标识
				school_types("").then(res => {
					let temp = []
					res.data.map(item => {
						let obj = {
							name: item.dictLabel,
							value: item.dictValue
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				})
			},
			natures(flag) {
				this.popObj.popTypeName = "类别/性质"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = flag //自定义标识
				school_level("").then(res => {
					let temp = []
					res.data.map(item => {
						let obj = {
							name: item.dictLabel,
							value: item.dictValue
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				})
			},
			checkBtn(flag) {
				if (!this.province) this.showMsg('请先选择省份')
				this.popObj.popTypeName = "学校名称"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = flag //自定义标识
				let params = {
					province: this.province,
					schoolType: this.schoolLevel,
					schoolLevel: this.schoolTypes,
					userId: this.readData('useId')
				}
				schoolNames(params).then(res => {
					console.log('res', res)
					let temp = []
					res.data.map(item => {
						let obj = {
							name: item.sname,
							value: item.scode
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				})
			},
			//提交vuex
			display(item) {
				this.popObj.popTypeName = null
				this.popObj.popTypeValue = null
				this.popObj.popTitle = null
				this.popObj.popList = []
				this.popObj.showRightPop = false
				if (item.potypesignValue == 'S') {
					this.provinceName = ""
					this.provinceName = item.flag ? item.val.name : this.mitprovince(item.val, 'name')
					let province = item.flag ? item.val.value : this.mitprovince(item.val, 'value')
					this.$store.commit('probtn', province)
				}
				if (item.potypesignValue == 'L') {
					this.schoolTypesName = ""
					this.schoolTypesName = item.flag ? item.val.name : this.mitprovince(item.val, 'name')
					let schoolTypesId = item.flag ? item.val.value : this.mitprovince(item.val, 'value')
					this.$store.commit('typebtn', schoolTypesId)
				}
				if (item.potypesignValue == 'Y') {
					this.schoolLevelName = ""
					this.schoolLevelName = item.flag ? item.val.name : this.mitprovince(item.val, 'name')
					let LevelId = item.flag ? item.val.value : this.mitprovince(item.val, 'value')
					this.$store.commit('Levelbtn', LevelId)
				}
				if (item.potypesignValue == 'X') {
					console.log('item.val', item.val)
					this.schoolName = ""
					this.schoolName = item.flag ? item.val.name : this.mitprovince(item.val, 'name')
					let schollcode = item.flag ? item.val.value : this.mitprovince(item.val, 'value')
					this.$store.commit('CodeBtn', schollcode)
				}
			},
			//分析事件
			analyse() {
				let params = {
					schoolCode: this.schoolcode,
					schoolName: this.schollNameIut,
					schoolCodeInput: this.schoolcodeInput,
					userId: this.readData('useId'),
				}
				this.navgateTo('/pages/schoolDetail/schoolDetail', {
					params: JSON.stringify(params)
				})
				this.schoolcode = ''
				this.schollNameIut = ''
				this.schoolcodeInput = ''
				// this.$store.dispatch('clearState');
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #ededed !important;
	}
</style>